home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
flashpc.exe
/
VIODEMO.C
< prev
next >
Wrap
Text File
|
1993-03-25
|
35KB
|
1,396 lines
#include <fpclib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <math.h>
typedef struct TCell {
char Ch,Attr;
} TCell;
void ClearTime( void );
void Delay( int num );
void str(int num, int digits, char *st );
char UpCase( char ch );
void DisplayTime( int NTimes );
void TestBorderColor( void );
void TestClrWin( void );
void TestColorMsg( void );
void TestEditSt( void );
void TestFillColAttr( void );
void TestFillColCell( void );
void TestFillColChar( void );
void TestFillFrameAttr( void );
void TestFillFrameCell( void );
void TestFillFrameChar( void );
void TestFillRowAttr( void );
void TestFillRowCell( void );
void TestFillRowChar( void );
void TestGetFrameAttr( void );
void TestGetFrameCell( void );
void TestGetFrameChar( void );
void TestGetScrn( void );
void TestPutScrn( void );
void TestPutFrameAttr( void );
void TestPutFrameCell( void );
void TestPutFrameChar( void );
void TestGetCursorSize( void );
void TestFrameWin( void );
void TestSetCursorSize( void );
void TestRvsAttr( void );
void TestGetVideoMode( void );
void TestInitVideo( void );
void TestGetVideoCols( void );
void TestGetVideoPage( void );
void TestGetVideoInfo( void );
void TestSetVideoPage( void );
void TestWhereXYAbs( void );
void TestScrollLeft( void );
void TestScrollRight( void );
void TestScrollDown( void );
void TestScrollUp( void );
void TestWriteSt( void );
void TestWriteStln( void );
int GetMenuSelection( void );
char TCSet[32] = { 0,101, 0,0,0,0, 0,24,
57,213,192,0,0,0,95, 0,
8, 0, 0,0,0,0, 0, 0,
0, 0, 0,0,0,0, 0, 0
};
char VCSet[32] = { 0, 0, 0, 0,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255
};
int i,j,i1,k,ChOfs,TE,
H1,M1,S1,Sec100_1,
H2,M2,S2,Sec100_2,
t1,t2,t3,Total;
char St[256],Done;
void ClearTime()
{
H1 = M1 = S1 = Sec100_1 = 0;
H2 = M2 = S2 = Sec100_2 = 0;
Total = 0;
}
void Delay(num)
int num;
{
int i;
num *= 50;
for (i = 0; i <= num; i++)
;
}
void str(num,digits,st)
char *st;
int num,digits;
{
int i;
*(st+digits) = '\0';
for (i = digits-1; i >= 0; i--) {
*(st+i) = (char)( (num % 10) + 48 );
num /= 10;
}
}
char UpCase(ch)
char ch;
{
if (ch >= 'a' && ch <= 'z')
ch -= 32;
return(ch);
}
void DisplayTime(NTimes)
int NTimes;
{
char st[80];
WindowFP(15,10,65,14);
ClrWin( 15, 10, 65, 14, 48 );
FrameWin('╔','╗','╚','╝','═','║',48);
strcpy( st, "Total Time = " );
itoa( Total, &st[13], 10 );
ColorMsg( 17, 11, 48, st );
strcpy( st, "NTimes = " );
itoa( NTimes, &st[13], 10 );
ColorMsg( 17, 12, 48, st );
strcpy( st, "Average time = " );
itoa( Total / NTimes , &st[15], 10 );
strcat( st, " hundredths of a second" );
ColorMsg( 17, 13, 48, st );
for (i = 0; i < 3; i++)
FillRowAttr(16,i+11,50,48);
ColorMsg(18,14,144," Press any key to continue... ");
GetKey();
}
void TestBorderColor()
{
int i;
if ( VioMode == 7 ) {
ClrWin(1,1,80,25,7);
WindowFP(21,11,60,14);
ClrWin(21,11,60,14,48);
FrameWin('╔','╗','╚','╝','═','║',48);
ColorMsg(23,12,48,"Not Available on Monochrome monitors");
ColorMsg(23,13,48," Press any key to continue...");
WindowFP(1,1,80,25);
}
else {
GotoxyAbs(1,1);
for (i = 1; i <= 15; i++) {
BorderColor(i);
WriteStln("Press any key to continue...");
GetKey();
}
}
GetKey();
BorderColor(0);
}
void TestClrWin()
{
int Color,TopRow,BottomRow,LeftCol,RightCol;
ClrWin(1,1,80,25,7);
GotoxyAbs(1,1);
printf("\nEnter attribute value to clear screen with. 0-255 ==> ");
scanf("%d",&Color);
printf("\nEnter top row of area to clear. 1-25 ==> ");
scanf("%d",&TopRow);
printf("\nEnter left column of area to clear. 1-80 ==> ");
scanf("%d",&LeftCol);
printf("\nEnter bottom row of area to clear. %u-25 ==> ",TopRow);
scanf("%d",&BottomRow);
printf("\nEnter right column of area to clear. %u-80 ==> ",LeftCol);
scanf("%d",&RightCol);
FillRowCell(1,1,2000,(65 << 8) + 7);
ColorMsg(1,1,48,"Press any key to clear area");
GetKey();
ClrWin(LeftCol,TopRow,RightCol,BottomRow,Color);
ColorMsg(1,1,48,"Press any key to return to menu");
GetKey();
}
void TestColorMsg()
{
char Msg[256];
int i,Color,Char_Ofs = 1,TE = 0;
TextAttr = 7;
do {
ClrWin(1,1,80,25,7);
GotoxyAbs(1,1);
WindowFP(10,1,69,3);
FrameWin('╔','╗','╚','╝','═','║',TextAttr);
ColorMsg(12,2,TextAttr,
"Enter 'QUIT' for message when you want to quit this test");
WindowFP(1,4,60,7);
FrameWin('╔','╗','╚','╝','═','║',TextAttr);
ColorMsg(3,4,TextAttr," ColorMsg data ");
ColorMsg(3,5,TextAttr,"Enter message to display ==> ");
for (i = 0; i < 255; Msg[i++] = '\0')
;
EditSt(5,32,59,28,0,32,0,7000,2000,VCSet,TCSet,&Char_Ofs,&TE,Msg);
ColorMsg(3,6,TextAttr,"Enter the color to display message in ==> ");
GotoxyAbs(44,6);
scanf("%d",&Color);
WindowFP(1,10,50,14);
FrameWin('╔','╗','╚','╝','═','║',TextAttr);
ColorMsg(3,11,Color,Msg);
RvsAttr(TextAttr);
ColorMsg(2,13,TextAttr,
" Press any key to continue... ");
RvsAttr(TextAttr);
GetKey();
for (Color = 0; Color < 4; Color++)
if (Msg[Color] >= 'a' && Msg[Color] <= 'z')
Msg[Color] -= 32;
} while (strcmp(Msg,"QUIT"));
}
void TestEditSt()
{
char St[256];
int i,Char_Ofs,TE;
ClrWin(1,1,80,25,7);
ColorMsg(1,10,7,"Enter your name:");
for (i = 0; i <= 255; St[i++] = '\0')
;
Char_Ofs = 1;
TE = 0;
EditSt(10,18,28,30,1,7,0,7000,2000,VCSet,TCSet,&Char_Ofs,&TE,St);
RvsAttr(TextAttr);
GotoxyAbs(1,15);
WriteSt(St);
RvsAttr(TextAttr);
GetKey();
}
void TestFillColAttr()
{
int i,NTimes = 80;
ClrWin(1,1,80,25,7);
ClearTime();
for (i = 1; i <= NTimes; i++) {
GetTime(&H1,&M1,&S1,&Sec100_1);
FillColAttr(i,1,25,i*16);
GetTime(&H2,&M2,&S2,&Sec100_2);
if ((Sec100_2 > Sec100_1) || ((S1 == S2) && (Sec100_1 == Sec100_2)))
Total = Total + (Sec100_2 - Sec100_1);
else {
t1 = 100 - Sec100_1 + Sec100_2;
Total = Total + t1;
};
};
DisplayTime(NTimes);
}
void TestFillColCell()
{
int i,
NTimes = 80;
ClrWin(1,1,80,25,7);
ClearTime();
for (i = 1; i <= NTimes; i++) {
GetTime(&H1,&M1,&S1,&Sec100_1);
FillColCell(i,1,25,((i+64) << 8) + i);
GetTime(&H2,&M2,&S2,&Sec100_2);
if ((Sec100_2 > Sec100_1) || ((S1 == S2) && (Sec100_1 == Sec100_2)))
Total = Total + (Sec100_2 - Sec100_1);
else {
t1 = 100 - Sec100_1 + Sec100_2;
Total = Total + t1;
};
};
DisplayTime(NTimes);
}
void TestFillColChar()
{
int i,
NTimes = 80;
ClrWin(1,1,80,25,7);
ClearTime();
for (i = 1; i <= NTimes; i++) {
GetTime(&H1,&M1,&S1,&Sec100_1);
FillColChar(i,1,25,(char)(i+64) );
GetTime(&H2,&M2,&S2,&Sec100_2);
if ((Sec100_2 > Sec100_1) || ((S1 == S2) && (Sec100_1 == Sec100_2)))
Total = Total + (Sec100_2 - Sec100_1);
else {
t1 = 100 - Sec100_1 + Sec100_2;
Total = Total + t1;
};
};
DisplayTime(NTimes);
}
void TestFillFrameAttr()
{
int i,
NTimes = 15;
ClrWin(1,1,80,25,7);
ClearTime();
for (i = 1; i <= NTimes; i++) {
GetTime(&H1,&M1,&S1,&Sec100_1);
FillFrameAttr(1,1,80,25,i << 4);
GetTime(&H2,&M2,&S2,&Sec100_2);
if ((Sec10